package router

import (
	"gin_api_demo/configs"
	"gin_api_demo/handler"
	"gin_api_demo/middleware"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

func Setup() *gin.Engine {
	gin.SetMode(configs.Conf.Mode)

	r := gin.New()

	// 注册两个自定义的中间件
	r.Use(middleware.Cors())
	r.Use(middleware.GinLogger(zap.L()))
	r.Use(middleware.GinRecovery(zap.L(), false))

	// 基础路由
	r.GET("/ping", handler.PingHandler)

	// 路由拆分

	return r
}
